<%@ include file="/common/taglibs.jsp"%>
<%@ page pageEncoding="utf-8"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>部门信息</title>
<link href="./styles/layout.css" rel="stylesheet" type="text/css" />	 
<script src="<c:url value='/scripts/common.js'/>"></script>
</head>
     
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	background-color: #F4F4F4;
}
-->
</style>
<body>
<bean:define id="form" name="departmentForm"
	type="com.sasis.webapp.form.DepartmentForm" />
<html:form action="deptInfoAction.html?method=save&fromWhere=updatePage">
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td height="25" class="home-content-title">
    <img src="images/edit.gif" align="absmiddle"/>&nbsp;部门管理</td>
  </tr>
    <logic:messagesPresent>
		<tr id="messagesPresentTrId" style="display:;">
			<td valign="top" class="black12" height="20">
				<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
					<tr>
						<td class="arror_bg">
							<span class="arror_title">
						     您的操作存在如下错误：<br></span>
						     <html:errors/>
					    </td>
				    </tr>
			    </table>
			</td>
		</tr>
  </logic:messagesPresent>
  <tr id="messageShowTrId" style="display:none;">
	<td valign="top" class="black12">
	<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
	<tr>
	<td class="arror_bg">
	<span class="arror_title"> 
     您的操作存在如下错误：<br/>
     </span>
     <span id="warnSaveMsgSpanId" style="display:none">
      <li>保存信息失败
     </span>
     <span id="warnMsgSpanId" style="display:none">
      <li><c:out value="${message}"/>
     </span>
      <span id="warnDepSpanId" style="display:none">
      <li>上级部门不允许选择当前部门
     </span>
    </td>
    </tr>
    </table>
	</td>
  </tr>
  <tr>
    <td height="20" class="home-search-space">&nbsp;带*标志的选项为必填项。</td>
  </tr>
  <tr>
    <td valign="top"> 
      <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
        <tr> 
          <td class="home-table-topline"> </td>
        </tr>
        <tr> 
          <td class="home-table-leftline"><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr> 
                <td class="home-table-tool-content">
				<input name="Submit1" type="button" class="home-inputBtn" onclick="javascript:newSubmit('save');" value="保存">
                <input name="Submit3" type="button" class="home-inputBtn" onclick=" document.forms[0].reset();" value="重写">
                <input name="Submit32" type="button" class="home-inputBtn" onclick="window.close();" value="取消"></td>
              </tr>
              <tr>
                <td align="center" valign="top">&nbsp;</td>
              </tr>
              <tr> 
                <td valign="top" class="home-edittable-space"> <table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr> 
                      <td><table width="100%" border="0" cellpadding="4" cellspacing="1" class="home-subtable-bgcolor">
                          <tr> 
                            <td width="30%" class="home-subtable-view-tdstyle-right">
                            <font color="red">*</font><fmt:message key="dept.common.code"/>：</td>
                            <td class="home-subtable-view-tdstyle-left">
                            <html:text property="code" size="20" styleClass="home-table-inputbox"/>
                            </td>
                          </tr>
    
                          <tr> 
                            <td class="home-subtable-view-tdstyle-right">
                            <font color="red">*</font><fmt:message key="dept.common.name"/></td>
                            <td colspan="3" class="home-subtable-view-tdstyle-left">
                            <html:text property="name" size="20" styleClass="home-table-inputbox"/></td>
                          </tr>
                          
                          <tr> 
                            <td class="home-subtable-view-tdstyle-right">
                            <fmt:message key="dept.common.superDept"/></td>
                            <td colspan="3" class="home-subtable-view-tdstyle-left">
                            <html:text property="parentName" styleId="selectedText" readonly="true"
                            style="border:0" styleClass="home-subtable-view-tdstyle-left"/>
        	                <html:hidden property="parentId" styleId="selectedId"/>
        	                </td>
                          </tr>
                        </table></td>
                    </tr>
                  </table> 
                  
                </td>
              </tr>
            </table>
		  </td>
        </tr>
        <tr> 
          <td height="12">
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr> 
                <td class="home-table-bottom-left">&nbsp;</td>
                <td class="home-table-bottom-bg">&nbsp;</td>
                <td class="home-table-bottom-right">&nbsp;</td>
              </tr>
            </table></td>
        </tr>
      </table>
	  
	  </td>
  </tr>
  <tr>
    <td height="10">&nbsp;</td>
  </tr>
</table>
<html:hidden property="id" />
<html:hidden property="aryId" /> 
</html:form> 
<script>
	
	function newSubmit(method){
		var dName = document.forms[0].name.value;
		var code = document.forms[0].code.value;
		var pName = document.getElementById("selectedText").value;
		
		    var messageShowTrId=document.getElementById("messageShowTrId");
 			var messagesPresentTrId=document.getElementById("messagesPresentTrId");
 			var warnSaveMsgSpanId=document.getElementById("warnSaveMsgSpanId");
 			var warnMsgSpanId=document.getElementById("warnMsgSpanId");
 			var warnDepSpanId=document.getElementById("warnDepSpanId");
 			
		
		//if(document.forms[0].name.value==""){
			//alert("部门名称不能为空");
			//return;
		//}else
	   if(dName!=""&&dName==pName){
			//alert('上级部门不允许选择当前部门!');
			if(messageShowTrId!=null)
 			   messageShowTrId.style.display="";
 			if(warnDepSpanId!=null)
 			   warnDepSpanId.style.display="";
 			if(messagesPresentTrId!=null&&messagesPresentTrId.style.display=="")
 			   messagesPresentTrId.style.display="none";
 			if(warnMsgSpanId!=null&&warnMsgSpanId.style.display=="")
 			   warnMsgSpanId.style.display="none";
 			if(warnSaveMsgSpanId!=null&&warnMsgSpanId.style.display=="")
 			   warnSaveMsgSpanId.style.display="none";
			//return;
		//}else if(""==code){
			//alert('部门代码不能为空!');
			//return;
		//}//else if(code.length>4){
			//alert('部门代码不能超出4位!');
			//return;
		}
		else
		{
		    //document.forms[0].method.value = method;
		    document.forms[0].submit();
		    //window.opener.location='./deptInfoAction.html?method=list';
		 }   
	   //window.close();
	    
     }
</script>
<script>
	var message = "<c:out value="${message}"/>";
	
	        var messageShowTrId=document.getElementById("messageShowTrId");
 			var messagesPresentTrId=document.getElementById("messagesPresentTrId");
 			var warnSaveMsgSpanId=document.getElementById("warnSaveMsgSpanId");
 			var warnMsgSpanId=document.getElementById("warnMsgSpanId");
 			var warnDepSpanId=document.getElementById("warnDepSpanId");
	
	if(message=="success") {
	 	//alert("保存信息成功!"); 
		//refreshParent();
		var url = opener.parent.location.href;
		var newurl = url;
		if(null!=url && ""!=url && url.indexOf("delete")!=-1){
			newurl=url.replace("delete","list")+"&pageIndex="+"<c:out value="${pageIndex}"/>";
		}
		opener.parent.location.href=newurl;
	 	window.close();
		
	}else if(message=="failure"){
		//alert("保存信息失败!");
		if(messageShowTrId!=null)
 			   messageShowTrId.style.display="";
 			if(warnSaveMsgSpanId!=null)
 			   warnSaveMsgSpanId.style.display="";
 			if(messagesPresentTrId!=null&&messagesPresentTrId.style.display=="")
 			   messagesPresentTrId.style.display="none";
 			if(warnMsgSpanId!=null&&warnMsgSpanId.style.display=="")
 			   warnMsgSpanId.style.display="none";
 			if(warnDepSpanId!=null&&warnMsgSpanId.style.display=="")
 			   warnDepSpanId.style.display="none"; 
	}else if(""!=message){
		//alert(message);
		if(messageShowTrId!=null)
 			   messageShowTrId.style.display="";
 			if(warnMsgSpanId!=null)
 			   warnMsgSpanId.style.display="";
 			if(messagesPresentTrId!=null&&messagesPresentTrId.style.display=="")
 			   messagesPresentTrId.style.display="none";
 			if(warnSaveMsgSpanId!=null&&warnSaveMsgSpanId.style.display=="")
 			   warnSaveMsgSpanId.style.display="none";
 			if(warnDepSpanId!=null&&warnMsgSpanId.style.display=="")
 			   warnDepSpanId.style.display="none"; 
		//window.close();
	}	

</script> 
</body>
</html>
